package com.warm.mini.wework.model;

import javafx.geometry.Pos;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author warmchuang
 * @date 2023/12/9 18:13
 * @desc
 */
@Data
public class JsonConfig {
    private List<Poster> posters;

    @Data
    public static class Poster{
        private Integer type;
        private String name;
        private String sourceImg;
        private Integer watermarkWidth;
        private Integer watermarkHeight;
        private Integer xAxis;
        private Integer yAxis;
    }

    public Map<Integer, Poster> getPosterMap(){
        if(CollectionUtils.isEmpty(this.posters)){
            return new HashMap<>();
        }
        return posters.stream().collect(Collectors.toMap(Poster::getType, Function.identity()));
    }
}
